<template>
	<view>
		这里是联系我们页面
		<view class="vfor" v-for="(item,index) in list">{{item}}</view>
		<button @click="pullrefresh()">点我触发下拉刷新</button>
		<button @click="getdata()">uni.request</button>
		<button @click="setStorage()">存储本地数据</button>
		<button @click="getStorage()">获取本地数据</button>
		<button @click="removeStorage()">删除本地数据</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:['前端','java','大数据',132,'测试']
			}
		},
		methods: {
			pullrefresh(){
				uni.startPullDownRefresh();//触发下拉事件
				uni.stopPullDownRefresh()//结束下拉事件
			},
			getdata(){
				uni.request({
					url:'http://localhost:8082/api/getlunbo',
					method:"GET",
					success(res) {
						console.log(res);
					}
				})
			},
			setStorage(){
				uni.setStorage({
					key:'id',
					data:80,
					success() {
						console.log('存储成功');
					}
				})
			},
			getStorage(){
				uni.getStorage({
					key:'id',
					success(e) {
						console.log(e);
					}
				})
			},
			removeStorage(){
				uni.removeStorage({
					key:'id',
					success() {
						console.log('删除storage成功');
					}
				})
			}
		},
		onReachBottom() {
			console.log('上拉事件触发');//页面上拉事件，常用与下拉继续增加数据
			this.list = [...this.list,...['新增加','数据']]
		},
		onPullDownRefresh() {
			console.log('页面下拉刷新');
			setTimeout(()=>{
				uni.stopPullDownRefresh()
				this.list = ['前端','java'];
			},500)
		}
	}
</script>

<style>
	.vfor{
		/* height: 150px; */
	}
</style>
